package solitaire.presentation;

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;

import solitaire.controle.CSolitaire;

public class PSolitaire extends JPanel {
	
	private CSolitaire controller;
	
	public PSolitaire(CSolitaire controller, PSabot sabot, PColonne[] colonnes, PTasDeCartesColorees[] colorees)
	{
		this.controller = controller;
		
		this.setSize(new Dimension(780, 631));
		this.setPreferredSize(this.getSize());
		
		this.setLayout(null);
		
		sabot.setLocation(20,20);
		this.add(sabot, 0);
		
		for(int i = 0 ; i < colonnes.length ; i++)
		{
			colonnes[i].setLocation(i*90 + 20, 150);
			this.add(colonnes[i], 0);
		}
		
		for(int i = 0 ; i < colorees.length ; i++)
		{
			colorees[i].setLocation(680, i*120 + 80);
			this.add(colorees[i], 0);
		}
	}
	
	public static void main (String args []) {
		JFrame f = new JFrame("Test PSolitaire") ;
		f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		f.getContentPane ().setBackground(new Color(143, 143, 143));
		
		PCarte c1 = new PCarte("QH", null);
		c1.setFaceVisible(true);

		PCarte c2 = new PCarte("2D", null);
		c2.setFaceVisible(true);
		
		PCarte c3 = new PCarte("3D", null);
		c3.setFaceVisible(false);
		
		PCarte c4 = new PCarte("4D", null);
		c4.setFaceVisible(false);
		
		PCarte c5 = new PCarte("KC", null);
		c5.setFaceVisible(true);
		
		PTasDeCartes tas1 = new PTasDeCartes(null);
		PTasDeCartes tas2 = new PTasDeCartes(null);
		
		PSabot sabot = new PSabot(tas1, tas2, null);
		
		PColonne colonne[] = new PColonne[7];
		PTasDeCartes cachees[] = new PTasDeCartes[7];
		PTasDeCartesAlternees visibles[] = new PTasDeCartesAlternees[7];
		for(int i = 0 ; i < 7 ; i++) {
			cachees[i] = new PTasDeCartes(null);
			visibles[i] = new PTasDeCartesAlternees(null);
			colonne[i] = new PColonne(cachees[i], visibles[i], null);
		}
		
		PTasDeCartesColorees colorees[] = new PTasDeCartesColorees[4];
		for(int i = 0 ; i < 4 ; i++) {
			colorees[i] = new PTasDeCartesColorees(null);
		}
		
		PSolitaire solitaire = new PSolitaire(null, sabot, colonne, colorees);

		cachees[0].empiler(c3);
		tas1.empiler(c4);
		visibles[3].empiler(c2);
		tas2.empiler(c1);
		colorees[2].empiler(c5);
		
		f.getContentPane().add(solitaire);
		
		f.setVisible (true) ;
		f.pack();
		
		
		
	}

}
